package corej.course.collection.map;

import java.util.*;

public class TestMap {
    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        Map map = new TreeMap();
        map.put("Unix", "Hiloo");
        map.put("CoreC++", "Liucy");
        map.put("UC", "Liucy");
        map.put("CoreJava", "Huxz");

        // map.put(null,"ABC");
        // map.put("123",null);

        printKeyValuePairs(map);
        /*
           * System.out.println(map.put("CoreC++","Huxz"));
           * System.out.println(map.size());
           *
           * System.out.println(map.get("CoreC++"));
           */

    }

    public static void printValues(Map map) {
        Collection vs = map.values();
        Iterator it = vs.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
    }

    public static void printKeyValuePairs(Map map) {
        Set ks = map.keySet();
        Iterator it = ks.iterator();
        while (it.hasNext()) {
            Object key = it.next();
            Object value = map.get(key);
            System.out.println(key + "-----" + value);
        }
    }
}
